	// Added 20/04/2014
	FairServer_SafeZones_Enable = true;
	FairServer_SafeZones_InSafeZone_EnableGodMode = true;							// Turns on god mode while in the safe zone so nobody can die. 
	FairServer_SafeZones_InSafeZone_EnableZombieAggro = false;	
	FairServer_SafeZones_InSafeZone_EnableUnconsciousness = true;					// 
	FairServer_SafeZones_InSafeZone_EnableEntryMessage = true;						// Shows an entry message when a player enters the co-ordinates of a safe zone

	// NYA
	FairServer_SafeZones_InSafeZone_Vehicles_EnableVehicleLoot = true;				// Allows people to loot from unlocked vehicles within a safe zone.
	FairServer_SafeZones_InSafeZone_Vehicles_EnableMountedGuns = false;				// Allows people to shoot from a mounted gun. 
	FairServer_SafeZones_InSafeZone_Vehicles_EnableGearingInVehicles = true;		// Allow people to gear while inside vehicles.
	
	FairServer_SafeZones_InSafeZone_EnableWeaponShooting = false;					// Allow retards and assholes to shoot eachother while in the safe zone? 
	FairServer_SafeZones_InSafeZone_EnableVehicleDamage = false;					// Allow assholes and retards to shoot and damage other people's cars? 
	FairServer_SafeZones_InSafeZone_EnableVehicleAutoRepair = true;					// Allow vehicles to be automatically repaired.
	FairServer_SafeZones_InSafeZone_EnableVehicleAutoRefuel = true;					// Allow vehicles to be automatically refuelled.
	
	FairServer_SafeZones_InSafeZone_BackPacks_EnableTheftProtection = true;			// Prevents non-friendly players from opening anyone else's backpack.
	FairServer_SafeZones_InSafeZone_BackPacks_FriendlyTaggedAccessEnabled = true;	// Allows people who have tagged eachother as friendly to access eachothers backpacks.
	FairServer_SafeZones_InSafeZone_Loot_EnableLootPileLooting = true;				// Allows people to loot from loot piles which have been placed on the floor

	// Used in the future to break the main loop. For now, always true.
	_continueExecution = true;
	
	// Events
	_FairServer_EventHandler_WeaponFired = objNull;
	_FairServer_EventHandler_VehicleWeaponFired = objNull;
	
	// Cache when user is in safezone. Otherwise, loop will go crazy initialising variables over and over again.
	_entryMessageShown = false; 
	_godModeEnabled = false;
	_enableWeaponShooting = false;
	_enableUnconsciousness = false;
	_enableZombieAggro = false;
	_enableMountedGuns = false;
	_enableAutoRepair = false;
	_enableAutoRefuel = false;
	_allRepaired = false;
	_allRefuelled = false;
	
	_playerInVehicle = objNull;
	_playerInVehicleLast = objNull;
	
	while{_continueExecution} do {
		waitUntil{!canBuild};
		
		/*
			Player can be either in a vehicle as driver, as something else, or just walking.
		*/
		while{!canBuild} do
		{
				if(FairServer_SafeZones_Enable) then
				{	
						/*
							Show player the entry message
						*/
						if(FairServer_SafeZones_InSafeZone_EnableEntryMessage) then
						{
								_EntryMessage = "You're now in a safe zone. The following features are enabled:";
								_extraFeaturesMessage = "";
								_tmpAppendMessage = "";
								
								if(FairServer_SafeZones_InSafeZone_EnableGodMode) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "GodMode: ON | ";
								};
								if(!FairServer_SafeZones_InSafeZone_EnableGodMode) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "GodMode: OFF | ";
								};
								if(FairServer_SafeZones_InSafeZone_BackPacks_EnableTheftProtection) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "TheftProtection: ON | ";
								};
								if(!FairServer_SafeZones_InSafeZone_BackPacks_EnableTheftProtection) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "TheftProtection: OFF | ";
								};		
								if(FairServer_SafeZones_InSafeZone_Vehicles_EnableAutoLock) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "AutoLock: ON | ";			
								};
								if(!FairServer_SafeZones_InSafeZone_Vehicles_EnableAutoLock) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "AutoLock: OFF | ";					
								};
								if(FairServer_SafeZones_InSafeZone_EnablePlayerVersusPlayer) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "Retards: ON | ";						
								};
								if(!FairServer_SafeZones_InSafeZone_EnablePlayerVersusPlayer) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "Retards: OFF | ";							
								};			
								if(FairServer_SafeZones_InSafeZone_EnableVehicleDamage) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "VehicleDmg: ON | ";						
								};
								if(!FairServer_SafeZones_InSafeZone_EnableVehicleDamage) then
								{
									_extraFeaturesMessage = _extraFeaturesMessage + "VehicleDmg: OFF | ";					
								};

								if(!_entryMessageShown) then
								{
									systemChat(_EntryMessage);
									systemChat(_extraFeaturesMessage);	
									_entryMessageShown = true;
								}

						};
							
						/*
							Enable god mode.
							
							Cached as it only needs to be set once!
						*/
						if(FairServer_SafeZones_InSafeZone_EnableGodMode && !_godModeEnabled) then
						{
								// Disable DayZ Damage handler
								fnc_usec_damageHandler = {};
								
								//ARMA2-specific functions (Remove damage handlers)
								player removeAllEventHandlers "handleDamage";
								player addEventHandler["handleDamage",{false}];
								player allowDamage false;
								
								_godModeEnabled = true;
						};
						
						/*
							Disable the firing of weapons.
							
							Cached as it only needs to be set once!
						*/
						if(!FairServer_SafeZones_InSafeZone_EnableWeaponShooting && !_enableWeaponShooting) then
						{	
							_FairServer_EventHandler_WeaponFired = player addEventHandler["Fired",{
									systemChat("Firing within the SafeZone is disabled.");
									NearestObject [_this select 0,_this select 4] setPos[0,0,0];
							}];
							
							_enableWeaponShooting = true;
						};
						
						/*
							Prevent person from falling unconscious.
							
							Cached as it only needs to be set once!
						*/
						if(!FairServer_SafeZones_InSafeZone_EnableUnconsciousness && !_enableUnconsciousness) then
						{
							// Remove DayZ unconsciousness handler.
							fnc_usec_unconscious  = {};
							
							_enableUnconsciousness = true;
							
						};
						
						/*
							Prevent zombies from attacking player.
							
							Cached as it only needs to be set once!
						*/
						if(!FairServer_SafeZones_InSafeZone_EnableZombieAggro && !_enableZombieAggro) then
						{
								// Disable DayZ player_zombieCheck.sqf (Zombie AI)
							player_zombieCheck = {};
							
							_enableZombieAggro = true;
						};
					
							// Player is in a vehicle
						if(vehicle player != player) then
						{
								// Get the current vehicle
								_inThisVehicle = vehicle player;
							
								// The type of vehicle in the safe zone.
								_type = typeOf _inThisVehicle;
								
								// Name of the vehicle
								_name = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
								
								
								/*
										Automatically refuel.
								*/
								if(FairServer_SafeZones_InSafeZone_EnableVehicleAutoRefuel && !_allRefuelled) then
								{
									_inThisVehicle setFuel 1;
									titleText [format["Your %1 was refuelled!", _name], "PLAIN DOWN", 2];
									_allRefuelled = true;
								};
								
								
								/*
									Call this after we've got vehicle information. We're not wrapping 
									all of this area as there are more than one use for it.
								*/
								if(FairServer_SafeZones_InSafeZone_EnableVehicleAutoRepair && !_allRepaired) then
								{
										
										// Find out how many hit points the vehicle has.
										_thisVehicleHitPoints = _inThisVehicle call vehicle_getHitPoints;

										{
											// Gets the current damage from the object and populates _x
											_currentDamage = [_inThisVehicle,_x] call object_getHit;
											
											// Make sure that the part is actually damaged.
											if(_currentDamage >0) then
											{	
							
												// Get information on the part.
												_vehiclePartName = toArray _x;
												_vehiclePartName set [0,20];
												_vehiclePartName set [1,45];
												_vehiclePartName set [2,20];
												_vehiclePartName = toString _vehiclePartName;

												// Seems Alex's script has an issue here, as object_getHit.sqf:4 already does typeOf!
												_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _x >> "name");
												
												// Calls DayZ script object_setFixServer to fix the selected item, provides the vehicle instance, the string for the vehicle's hitpoints and the param "0" which means repair.
												[_inThisVehicle	,_selection,0] call object_setFixServer;
												
												// Tell the user it's fixed.
												titleText [format["Repaired %1 ...", _vehiclePartName], "PLAIN DOWN", 2];
												
											};
										} forEach _thisVehicleHitPoints;	
										_allRepaired = true;
								};
							
						};
				};
		};
		
		waitUntil{canBuild};
		
		// Unset above cache variables.
		_entryMessageShown = false; 
		_godModeEnabled = false;
		_enableWeaponShooting = false;
		_enableUnconsciousness = false;
		_enableZombieAggro = false;
		_enableMountedGuns = false;
		_enableAutoRepair = false;
		_exitMessageShown = false;
		_allRepaired = false;
		_allRefuelled = false;
		
		while{canBuild} do
		
		{
				if(FairServer_SafeZones_Enable) then
				{	
						if(FairServer_SafeZones_InSafeZone_EnableEntryMessage) then
						{	
							if(!_exitMessageShown) then
							{
								_ExitMessage = "You're now out of the safe zone. You're on your own.";
								systemChat(_ExitMessage);
								
								_exitMessageShown = true;
							}

						};
						
						if(!FairServer_SafeZones_InSafeZone_EnableWeaponShooting) then
						{
							player removeEventHandler ["Fired", _FairServer_EventHandler_WeaponFired];
						};
						
						if(!FairServer_SafeZones_InSafeZone_EnableUnconsciousness) then
						{
							// Remove DayZ unconsciousness handler.
							fnc_usec_unconscious = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_unconscious.sqf";
						};
						
						if(FairServer_SafeZones_InSafeZone_EnableGodMode) then
						{	
								// Re-supply DayZ with damage calculation parameters.
								fnc_usec_damageHandler = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_damageHandler.sqf";
							
								player removeAllEventHandlers "handleDamage";
								player addEventHandler ["handleDamage", {true}];
								
								player allowDamage true;
						};
						
						if(!FairServer_SafeZones_InSafeZone_EnableZombieAggro) then
						{
								// Re-supply DayZ with zombie AI.
								player_zombieCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_zombieCheck.sqf";
						};				

				};		
		};	
	};